package cn.edu.zafu.bigdata.lwg;

class InvalidScoreException extends Exception {
    public InvalidScoreException(String message) {
        super(message);
    }
}

public class ScoreValidation {

    public static void main(String[] args) {
        int score = -5;

        try {
            checkScore(score);
        } catch (InvalidScoreException e) {
            System.out.println("错误：" + e.getMessage());
        }
    }

    public static void checkScore(int score) throws InvalidScoreException {
        if (score < 0 || score > 100) {
            throw new InvalidScoreException("分数必须在0到100之间。");
        } else {
            System.out.println("分数有效：" + score);
        }
    }
}